Skip to content

Conversation

@BoykoDmitry
Copy link
Owner

Add Web API project for database extraction service

Summary

This PR adds a new ASP.NET Core Web API project (ParameterizationExtractor.WebApi) that exposes the existing database extraction functionality as a REST service. The API accepts extraction configurations in JSON, XML, and DSL formats, processes them using the existing PackageProcessor logic, and returns generated SQL scripts as a ZIP file.

Key Features Added:

  • POST /api/extraction/extract - Main extraction endpoint accepting configuration and connection string
  • GET /api/extraction/health - Health check endpoint
  • GET /api/extraction/formats - Documentation showing supported formats with examples
  • Support for JSON, XML, and DSL configuration formats
  • ZIP file response containing generated SQL scripts
  • Swagger documentation integration

Architecture Changes:

  • Created ApiAppArgs to bridge between API context and existing CLI-focused IAppArgs interface
  • Reused existing PackageProcessor, ConfigSerializer, and all extraction logic
  • Added proper dependency injection setup following existing patterns from AppBootstrap.cs
  • Integrated with existing F# DSL parsing via FparsecConnector

Review & Testing Checklist for Human

  • Build verification: Verify the project builds successfully and all dependencies resolve correctly (highest priority - I couldn't test compilation locally)
  • End-to-end API testing: Test the API with real database connections and various configuration formats to ensure the extraction actually works and produces valid SQL scripts
  • Dependency injection validation: Check that all services are registered with correct lifetimes and that the ApiAppArgs approach properly handles scoped scenarios
  • JSON format correctness: Validate that the JSON-to-Package conversion logic correctly maps extraction strategies and SQL build options to the internal model classes
  • Resource cleanup: Verify that temporary directories and files are properly cleaned up in all scenarios (success, failure, exceptions)

Test Plan Recommendation:

  1. Start the API and verify Swagger UI loads at /swagger
  2. Test each configuration format (JSON, XML, DSL) with a simple extraction scenario
  3. Verify the returned ZIP file contains valid SQL scripts
  4. Test error scenarios (invalid config, bad connection string, etc.)
  5. Check that no temp files are left behind after multiple requests

Notes

  • Risk Level: 🟡 Medium - Complex integration with existing CLI codebase, unable to test locally due to missing .NET CLI tools
  • Connection strings are handled via environment variables which may need review for production scenarios
  • The API reuses all existing extraction logic without modification, maintaining consistency with CLI behavior
  • Session requested by: @BoykoDmitry
  • Link to Devin run: https://app.devin.ai/sessions/646201de187c4d9b9a274581067cf14a

- Created new ParameterizationExtractor.WebApi project with REST endpoints
- Added support for JSON, XML, and DSL configuration formats
- Implemented ZIP file response containing generated SQL scripts
- Integrated existing PackageProcessor and extraction logic
- Added proper dependency injection setup following existing patterns
- Created ApiAppArgs for Web API context without CLI dependencies
- Added Swagger documentation and health check endpoints
- Updated solution file to include new Web API project

The API exposes:
- POST /api/extraction/extract - Main extraction endpoint
- GET /api/extraction/health - Health check
- GET /api/extraction/formats - Documentation of supported formats

This enables the ParameterizationExtractor to work as a service with REST API
while maintaining all existing CLI functionality.

Co-Authored-By: [email protected] <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants